/**
 * \file OgreCharacter.h
 * \author Niels van Galen Last & Erik Kok
 * \date 01-15-08
 */
#ifndef OGRE_CHARACTER_H
#define OGRE_CHARACTER_H


// Specialization of the Character class - Our dear Ogre :D
#include <list>

#include "Character.h"

#include "BeamWeapon.h"

#include "OgreOde_Core/OgreOde_Core.h"
#include "CollidingObject.h"
#include "Enemy.h"
#include "EnemyManager.h"
#include "InfoManager.h"

/**
 * Class OgreCharacter
 *
 * Used to create and manage the main character from this game, the aircraft. Also this funtion handles the collision and bullets.
 */
class OgreCharacter : public Character, public OgreOde::CollisionListener, public virtual CollidingObject
{
public:
	/// Overloaded constructor
	OgreCharacter (String name, OgreOde::World *world);

	/// Default destructor
	~OgreCharacter ();

	/**
	 * Sets the enemy manager
		\param EmenyManger The Enemymanager you want to use
	 */
	void set_enemy_manager( EnemyManager* enemy_manager ) { this->enemy_manager = enemy_manager; }

	/// Change visibility of the ogre - Useful for 1st person view
	void setVisible (bool visible) { mMainNode->setVisible (visible); }

	/**
	 * Sets the info manager
		\param InfoManger The InfoManager you want to use
	 */
	void set_info_manager(InfoManager * info_manager);
	
	/**
	 * Returns the lives left
		\return int The lives
	 */
	int get_lives() { return lives; }

	/**
	 * Returns whether the character is alive or not
		\return bool If the player is alive or not
	 */	
	bool is_alive() { return ( lives > 0 ) ? true : false; }

	/**
	 * Returns the number of boosts
		\return int The boosts
	 */	
	int get_boost() { return (int) boost - 1; }

	/**
	 * Returns the time left for the boost to end
		\return int The boosttime left
	 */
	int get_boost_timer() { return boost_timer; }
	
	/// Create a new powerup
	void create_powerup(Vector3 position);


private:
	void update (Real elapsedTime, OIS::Keyboard *input, OIS::Mouse* mouse);
    virtual bool collision(OgreOde::Contact* contact);

	unsigned int beam_c;
	float shoot_timer;
	
	std::vector<BeamWeapon*> beam_stack;
	std::vector<BeamWeapon*> active_beams;

	std::vector<BeamWeapon*>::iterator beam_iter;

	list<OgreOde::Geometry*> delete_list;

	EnemyManager* enemy_manager;
	unsigned int speed, boost;
	float boost_timer;

	InfoManager* info_manager;

	int lives;

	unsigned int powerup_counter;

    OgreOde::InfinitePlaneGeometry  *mGround;    
    OgreOde::Body                   *mBody;
    OgreOde::Body                   *mBody2;
    OgreOde::Geometry               *mGeom;
    OgreOde::Geometry               *mGeom2;
    OgreOde::Geometry               *mGeom3;
    OgreOde::World                  *mWorld;
    OgreOde::BoxMass                *mMass;
    OgreOde::Space                  *mSpace;
    OgreOde::StepHandler            *mStepper;

    Ogre::SceneNode                 *mNode;
    Ogre::Entity                    *mEntity;
    int i;

protected:
	String mName;
	Vector3 mTranslateVector;
   	Real mTimeUntilNextToggle ;
	Radian mRotX, mRotY;
    Real _thrust,_linear_damp,_angular_damp;
    Vector3 _thrust_offs,_thrust_force;
};

#endif
